DC MOTOR INTERFACING WITH RASPBERRY Pi
In this project we are going to control the DC motor with the help of L293D motor driver connected to Raspberry Pi.
Synopsis:

In this project we are going to control the DC motor with the help of L293D motor driver connected to Raspberry Pi.

Description:


Dc motor:

DC motor is a device that converts electrical energy into mechanical energy. The Dc motor operates in Dc voltage and current, and it does not have any specific positive and negative terminal. This means that the rotates in clockwise or anticlockwise direction based on the connection provide at the motor terminal. This direction can be controlled using L293D IC.

L293D:

L293D works on the “H-bridge” principle which allows DC motor to rotate or drive in any direction. Using L293D we can control 2 motors simultaneously.

Raspberry Pi:

Raspberry Pi is a low cost, small size computer that plugs into a computer monitor, and uses a keyboard and mouse. It is capable device that enables us to explore computing and to learn how to program in languages like scratch and python. It is capable of doing what we expect a computer to do. It has many interfaces like HDMI, multiple USB, Ethernet, onboard Wi-Fi and Bluetooth, GPIOs, USB powered etc. also supports to LINUX, Python to make easy to build applications. Raspberry is available in different versions the latest version of Raspberry Pi is Pi3+ Model and the Updated version is Pi4 model. In Raspberry Pi 3B+ Model this model is having 64-bit quad core (processor) running at 1.4GHz, dual band 2.4GHz, 5GHz wireless LAN, Bluetooth 4.2/BLE, faster Ethernet, and PoE (power on Ethernet) capability with separate PoE HAT. Raspberry Pi3 Mode B+ maintains the same footprint as raspberry Pi2 and Raspberry Pi3 Model B.


Pin configuration:

1. Vin: Two 5v pins and two 3v3 pins used for providing power supply, where processor works on 3.3v.

2. Ground: Having 8 ground Pins which are un-configurable.

3. GPIO: There are 26 input-output pins which will be used as input or output based on programming.

4. PWM: In software PWM are available for all pins but in hardware PWM is available for GPIO12, GPIO13, GPIO18, and GPIO19.

5. 2 SPI bus: These pins are used for SPI communication the pins which are used for SPI is MISO, MOSI, SCLK, CE0, and CE1

6. I2C: These pins are used for I2C communication in which DATA and CLOCK pins are used for sending data to and from the SDA connection, with the speed controlled with SCL pin and ID-SE, ID-SC are reserved for ID EEPROM.

7. TX and RX: This pins are used for UART communication.

DC Motor Pin Configuration with Raspberry pi:

1. 4-Input pins: This pin is used to control the output.

2. 4-Output pins: This pin is used to connect another end of the motor.

3. 2-Enable pins: This pin is used to enable input.

4. 4-Ground pins: This pin is connected to the ground of the circuit (0v).

5. Vcc pin: This pin is connected to +5v.

6. Vs pin: this pin is connected to voltage pin to run motor (4.5v-36v).

Schematic:


Code:

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
IN1=16
IN2=18
GPIO.setup(IN1, GPIO.OUT)
GPIO.setup(IN2, GPIO.OUT)
print (“FORWARD MOTION”)
GPIO.OUTPUT(IN1, GPIO.HIGH)
GPIO.OUTPUT(IN2, GPIO.LOW)
time.sleep(3)
print (“BACKWARD MOTION”)
GPIO.OUTPUT(IN1, GPIO.LOW)
GPIO.OUTPUT(IN2, GPIO.HIGH)
time.sleep(3)
print (“Motor Stop”)
GPIO.OUTPUT(IN1, GPIO.LOW)
GPIO.OUTPUT(IN2, GPIO.LOW)
GPIO.cleanup()

Error message here!

Show Error message here!


Forgot your password?

Error message here!

Send OTP

Error message here!

Show Error message here!


Lost your password? Please enter your email address. You will receive a password you Need.

Send Error message here!


Back to log-in

Close